{// 引入标签库 }
<tagLib name="html" />
<include file="Public:header" />

<php>
	function getCouponUserName($user_id)
	{
		$user_info = M("User")->getById($user_id);
		if($user_info)
		return $user_info['user_name'];
		else
		return L("NOT_USER_COUPON");
	}
	function getCouponOrderSn($order_id)
	{
		$order_info = M("DealOrder")->getById($order_id);
		if($order_info)
		return $order_info['order_sn'];
		else
		return L("NOT_ORDER_COUPON");
	}
	function getCouponIsNew($is_new)
	{
		return l("COUPON_IS_NEW_".$is_new);
	}
	function getCouponIsValid($is_valid)
	{
		return l("COUPON_IS_VALID_".$is_valid);
	}
	function getCouponConfirmAccount($account_id)
	{
		return M("SupplierAccount")->where("id=".$account_id)->getField("account_name");
	}
</php>
<script type="text/javascript">
	function sms(id)
	{
		location.href = ROOT+"?"+VAR_MODULE+"="+MODULE_NAME+"&"+VAR_ACTION+"=sms&id="+id;
	}
	function mail(id)
	{
		location.href = ROOT+"?"+VAR_MODULE+"="+MODULE_NAME+"&"+VAR_ACTION+"=mail&id="+id;
	}
</script>
<div class="main">
<div class="main_title">[{$deal_info.name|msubstr}] {$main_title}</div>
<div class="blank5"></div>
<div class="button_row">
	<input type="button" class="button" value="{%ADD}" onclick="location.href='__APP__?m=DealCoupon&a=add&deal_id={$deal_info.id}';" />
	<input type="button" class="button" value="{%FOREVERDEL}" onclick="foreverdel();" />
	<input type="button" class="button" value="{%IMPORT_CSV}" onclick="location.href='__APP__?m=DealCoupon&a=import&deal_id={$deal_info.id}';" />
</div>
<div class="blank5"></div>
<div class="search_row">
	<form name="search" action="__APP__" method="get">	
		{%SN}：<input type="text" class="textbox" name="sn" value="{:trim($_REQUEST['sn'])}" style="width:100px;" />
		{%USER_ID}：<input type="text" class="textbox" name="user_id" value="{:trim($_REQUEST['user_id'])}" style="width:30px;" />
		{%COUPON_IS_VALID}: 
		<select name="is_valid">
				<option value="-1" <if condition="intval($_REQUEST['is_valid']) eq -1">selected="selected"</if>>{%ALL}</option>
				<option value="0" <if condition="intval($_REQUEST['is_valid']) eq 0">selected="selected"</if>>{%IS_VALID_0}</option>
				<option value="1" <if condition="intval($_REQUEST['is_valid']) eq 1">selected="selected"</if>>{%IS_VALID_1}</option>
		</select>
		{%COUPON_CONFIRM}: 
		<select name="is_confirm">
				<option value="-1" <if condition="intval($_REQUEST['is_confirm']) eq -1">selected="selected"</if>>{%ALL}</option>
				<option value="0" <if condition="intval($_REQUEST['is_confirm']) eq 0">selected="selected"</if>>{%NO}</option>
				<option value="1" <if condition="intval($_REQUEST['is_confirm']) eq 1">selected="selected"</if>>{%YES}</option>
		</select>

		<input type="hidden" value="DealCoupon" name="m" />
		<input type="hidden" value="index" name="a" />
		<input type="hidden" value="{:intval($_REQUEST['deal_id'])}" name="deal_id" />
		<input type="submit" class="button" value="{%SEARCH}" />
		<input type="button" class="button" value="{%EXPORT}" onclick="export_csv();" />
	</form>
</div>
<div class="blank5"></div>
<html:list 
	id="dataTable" 
	style="dataTable" 
	name="coupon" 
	checkbox="true" 
	action="true" 
	datasource="list" 
	show="id:{%ID}|50px
		,sn:{%COUPON_SN}:edit
		,password:{%COUPON_PASSWORD}
		,begin_time|to_date:{%COUPON_BEGIN_TIME}
		,end_time|to_date:{%COUPON_END_TIME}
		,user_id|getCouponUserName:{%COUPON_USER}
		,order_id|getCouponOrderSn:{%COUPON_ORDER}
		,is_new|getCouponIsNew:{%COUPON_IS_NEW}
		,is_valid|getCouponIsValid:{%COUPON_IS_VALID}
		,confirm_account|getCouponConfirmAccount:{%COUPON_CONFIRM_ACCOUNT}
		,confirm_time|to_date:{%COUPON_CONFIRM_TIME}" 
	actionlist="edit:{%EDIT}, foreverdel:{%FOREVERDEL},sms:{%SMS_COUPON},mail:{%MAIL_COUPON}" /> 

<div class="blank5"></div>
<div class="page">{$page}</div>
</div>
<include file="Public:footer" />